package id.net.iconpln.bb.client.view;

import id.net.iconpln.bb.client.model.Stock;
import id.net.iconpln.bb.client.service.PortRPCService;
import id.net.iconpln.bb.client.service.PortRPCServiceAsync;
import id.net.iconpln.bb.client.util.ClientModule;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.DateTimePropertyEditor;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.MultiField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.TimeField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class PageBbPortBongkar extends LayoutContainer {
	private final PortRPCServiceAsync service = GWT.create(PortRPCService.class);
	private FormBinding formBindings;  
	private FormData formData; 
	private ListStore storeKplBongkar,storeKplAntri, storeJetty,storeKplSandar;
	private Grid gridKplBongkar, gridKplAntri,gridKplSandar;
	private ComboBox cboJetty;
	private DateField tglTa, time_bongkarD,time_sandarD,time_selesaiD;
	private TextField<String> noAntri,ash_kirim,cv_kirim,ts_kirim,tm_kirim;
	private TimeField time_bongkarT,time_sandarT,time_selesaiT;
	private Button bSubmit;
	private MultiField multiSelesai;
	
	
	  @Override  
	  protected void onRender(Element parent, int index) {  
	    super.onRender(parent, index);  
	    setLayout(new FitLayout());
	    initStore();
	    
	    formData = new FormData("-20"); 
	    ContentPanel cp = new ContentPanel();  
	   
	    cp.setHeaderVisible(false);
	    cp.setFrame(true);  
	    cp.setSize(900, 400);  
	    cp.setLayout(new RowLayout(Orientation.HORIZONTAL)); 
	  
	    gridKplSandar = createGridSandar();  
	    gridKplSandar.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);  
	    gridKplSandar.getSelectionModel().addListener(Events.SelectionChange,  
	        new Listener<SelectionChangedEvent<BaseModel>>() {  
	          public void handleEvent(SelectionChangedEvent<BaseModel> be) {  
	            if (be.getSelection().size() > 0) {  	              
	            	bSubmit.setEnabled(true);
	            	multiSelesai.setVisible(false);
	              formBindings.bind((ModelData) be.getSelection().get(0));  
	            } else {  
	              formBindings.unbind();  
	            }  
	          }  
	        });
	    
	    
	    gridKplBongkar = createGridBongkar();
	    gridKplBongkar.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);  
	    gridKplBongkar.getSelectionModel().addListener(Events.SelectionChange,  
	        new Listener<SelectionChangedEvent<Stock>>() {  
	          public void handleEvent(SelectionChangedEvent<Stock> be) {  
	            if (be.getSelection().size() > 0) {  
	            	bSubmit.setEnabled(false);
	            	multiSelesai.setVisible(true);
	              formBindings.bind((ModelData) be.getSelection().get(0));  
	            } else {  
	              formBindings.unbind();  
	            }  
	          }  
	        });
	    ToolBar tbPltu = new ToolBar();
	    tbPltu.add(new LabelToolItem("<b>Data kapal Bongkar</b>"));
	    tbPltu.add(new SeparatorToolItem());
	    	    
//	    gridship = createGridPreshipment();
	    ToolBar tbSandar = new ToolBar();
	    tbSandar.add(new LabelToolItem("<b>Data Kapal Sandar</b>"));
	    tbSandar.add(new SeparatorToolItem());
	    
	    FormPanel panel = createForm(); 
	    panel.setScrollMode(Scroll.AUTO);
	    formBindings = new FormBinding(panel, true);  
//	    formBindings.setStore((Store) gridKplBongkar.getStore());  
	    
	    
	    ContentPanel pkirim = new ContentPanel();
	    pkirim.setHeaderVisible(false);
	    pkirim.setLayout(new FitLayout());
	    pkirim.add(gridKplBongkar);
	    pkirim.setTopComponent(tbPltu);
	    
	    aktivitasDermaga("antri","BONGKAR","", "");
	    aktivitasDermaga("antri","SANDAR","", "");
	    
	    ContentPanel pKplSandar = new ContentPanel();
	    pKplSandar.setHeaderVisible(false);
	    pKplSandar.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pKplSandar.add(gridKplSandar,new RowData(1, 1));
	    pKplSandar.setTopComponent(tbSandar);

	    ContentPanel pKplBongkar = new ContentPanel();
	    pKplBongkar.setHeaderVisible(false);
	    pKplBongkar.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pKplBongkar.add(gridKplBongkar,new RowData(1, 1));
	    pKplBongkar.setTopComponent(tbPltu);

	    
	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);
	    p.setLayout(new RowLayout(Orientation.VERTICAL));	    	    
	    p.add(pKplSandar, new RowData(.99, .5));
	    p.add(pKplBongkar, new RowData(.99, .5));
	    
	    cp.add(panel, new RowData(.4, 1));
	    cp.add(p, new RowData(.6, 1));
	    
	    
//		setScrollMode(Scroll.AUTO);		
	    add(cp, new FitData(5));  
	  }  
	  private void initStore(){
		  storeKplBongkar = new ListStore(); 
		  storeKplSandar = new ListStore(); 
//		  storeJetty = new ListStore();
	  }

	  private Grid createGridBongkar() {  
		  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     

		    column = new ColumnConfig();  
		    column.setId("no_bongkar");  
		    column.setHeader("No Bongkar");  
		    column.setWidth(150);  
		    configs.add(column); 
		    
		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Pemasok");  
		    column.setWidth(150);  
		    configs.add(column); 

		    
		    column = new ColumnConfig();  
		    column.setId("nama_transport");  
		    column.setHeader("Nama kapal");    
		    column.setWidth(150);    
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("no_pengiriman");  
		    column.setHeader("No Pengiriman");  
		    column.setWidth(100);  
		    configs.add(column);  	
		    
		    column = new ColumnConfig();  
		    column.setId("kode_jetty");  
		    column.setHeader("Jetty");  
		    column.setWidth(100);  
		    configs.add(column);  	  
		    
		    column = new ColumnConfig();  
		    column.setId("time_merapat");  
		    column.setHeader("Mulai Sandar");  
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy hh.mm"));
		    column.setWidth(150);  
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("time_bongkar");  
		    column.setHeader("Mulai Bongkar");  
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy hh.mm"));
		    column.setWidth(150);  
		    configs.add(column);
		    

		    storeKplBongkar.setMonitorChanges(true);  

		  
		    ColumnModel cm = new ColumnModel(configs);  
	  
	    gridKplBongkar = new Grid(storeKplBongkar, cm);  
	    gridKplBongkar.getView().setEmptyText("Data Empty");
	    gridKplBongkar.setLoadMask(true);  
	    gridKplBongkar.mask("load Data ...","x-mask-loading");
	    gridKplBongkar.setBorders(false);  
//	    grid.setAutoExpandColumn("pemasok");  
	    gridKplBongkar.setBorders(true);  
	    gridKplBongkar.addListener(Events.CellClick, new Listener<BaseEvent>() {            
        public void handleEvent(BaseEvent ge) {
        	try{


        		String mulai_sandar = gridKplBongkar.getSelectionModel().getSelectedItem().get("time_merapat");
        		String mulai_bongkar = gridKplBongkar.getSelectionModel().getSelectedItem().get("time_bongkar");
            	time_sandarT.setRawValue("00.00");
            	time_sandarD.setRawValue(mulai_sandar);
            	time_bongkarT.setRawValue("00.00");
            	time_bongkarD.setRawValue(mulai_bongkar);
            	ash_kirim.setValue(gridKplBongkar.getSelectionModel().getSelectedItem().get("ash").toString());
            	cv_kirim.setValue(gridKplBongkar.getSelectionModel().getSelectedItem().get("cv").toString());
            	ts_kirim.setValue(gridKplBongkar.getSelectionModel().getSelectedItem().get("ts").toString());
            	tm_kirim.setValue(gridKplBongkar.getSelectionModel().getSelectedItem().get("tm").toString());
            	
            	
        	}catch (Exception e) {
					// TODO: handle exception
        		e.getMessage();
				}

         	
        }
		});

	    return gridKplBongkar;  
	  }   
	 
 
	  
	  private FormPanel createForm() {  
	    FormPanel panel = new FormPanel();	    
	    panel.setHeaderVisible(false);
	    
	    FieldSet fieldSet = new FieldSet();  
	    fieldSet.setHeading("Pengajuan Bongkar");  
	    fieldSet.setCollapsible(false);
	    
	  
	    FormLayout layout = new FormLayout();  
	    layout.setLabelWidth(150);  
	    fieldSet.setLayout(layout);  

	    final TextField<String> no_bongkar = new TextField<String>();  
	    no_bongkar.setName("no_bongkar");  
	    no_bongkar.setFieldLabel("No Bongkar");    
	    fieldSet.add(no_bongkar, formData);	  	  
	    
	    TextField<String> no_pengiriman = new TextField<String>();  
	    no_pengiriman.setName("no_pengiriman");  
	    no_pengiriman.setFieldLabel("No Pengiriman");    
	    fieldSet.add(no_pengiriman, formData);	  	  
	    	     

//	    TextField<String> time_merapat = new TextField<String>();	    
//	    time_merapat.setName("time_merapat");  
//	    time_merapat.setFieldLabel("Mulai Sandar");    
//	    fieldSet.add(time_merapat, formData);
//
	    MultiField multiSandar = new MultiField();
	    multiSandar.setFieldLabel("Mulai Sandar");
	    multiSandar.setSpacing(10);
	
		time_sandarD = new DateField();
		time_sandarD.setWidth(90);
		time_sandarD.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));
  
		time_sandarT = new TimeField();
		time_sandarT.setWidth(90);
		
		multiSandar.add(time_sandarD);
		multiSandar.add(time_sandarT);
	    
		fieldSet.add(multiSandar, formData);

//	    TextField<String> time_bongkar = new TextField<String>();	    
//	    time_bongkar.setName("time_bongkar");  
//	    time_bongkar.setFieldLabel("Mulai Bongkar");    
//	    fieldSet.add(time_bongkar, formData);
	    
	    
	    MultiField multi = new MultiField();
		multi.setFieldLabel("Mulai Bongkar");
		multi.setSpacing(10);
	
		time_bongkarD = new DateField();
		time_bongkarD.setWidth(90);
		time_bongkarD.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));
  
		time_bongkarT = new TimeField();
		time_bongkarT.setWidth(90);
		
	    multi.add(time_bongkarD);
        multi.add(time_bongkarT);
	    
		fieldSet.add(multi, formData);
	    
	    multiSelesai = new MultiField();
	    multiSelesai.setFieldLabel("Selesai Bongkar");
	    multiSelesai.setSpacing(10);
	    multiSelesai.setVisible(false);
	
		time_selesaiD = new DateField();
		time_selesaiD.setWidth(90);
		time_selesaiD.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));
  
		time_selesaiT = new TimeField();
		time_selesaiT.setWidth(90);
		
		multiSelesai.add(time_selesaiD);
		multiSelesai.add(time_selesaiT);
	    
		fieldSet.add(multiSelesai, formData);
		
	    final TextField<String> alat_bongkar = new TextField<String>();	    
	    alat_bongkar.setName("alat_bongkar");  
	    alat_bongkar.setFieldLabel("Alat Bongkar");    
	    fieldSet.add(alat_bongkar, formData);
	    
	    	
	    TextField<String> nama_transport = new TextField<String>();
	    nama_transport.setName("nama_transport");  
	    nama_transport.setFieldLabel("Nama Kpl / Tongkang");	    
	    fieldSet.add(nama_transport, formData);
	    
	    TextField<String> kode_jetty = new TextField<String>();
	    kode_jetty.setName("kode_jetty");  
	    kode_jetty.setFieldLabel("Jetty");	    
	    fieldSet.add(kode_jetty, formData);
	    
	    
	    panel.add(fieldSet);  	     

	    FieldSet fieldSet2 = new FieldSet();  
	    fieldSet2.setHeading("Kualitas & Kuantitas Pengiriman");  
	    fieldSet2.setCollapsible(false);

	    FormLayout layout3 = new FormLayout();  
	    layout3.setLabelWidth(80);  
	    fieldSet2.setLayout(layout3);  

	    MultiField multi_kirim = new MultiField();
	    multi_kirim.setFieldLabel("Ash");
	    multi_kirim.setSpacing(30);
	    
	    ash_kirim = new TextField<String>();
	    ash_kirim.setName("ash");  
	    ash_kirim.setWidth(90);
	    ash_kirim.setReadOnly(true);
//	    ash_kirim.setFieldLabel("Ash");    
//	    fieldSet2.add(ash_kirim, formData);
	    multi_kirim.add(ash_kirim);   	    
	    
	    LabelField lcv = new LabelField("CV:");
	    lcv.setWidth(20);
	    multi_kirim.add(lcv);
	    
	    cv_kirim = new TextField<String>();	    
	    cv_kirim.setName("cv");  
	    cv_kirim.setWidth(90);
	    cv_kirim.setReadOnly(true);
//	    cv_kirim.setFieldLabel("CV");    
//	    fieldSet2.add(cv_kirim, formData);

	    multi_kirim.add(cv_kirim);
	    
	    fieldSet2.add(multi_kirim, formData);
	    
	    MultiField multi_kirim_tm_ts = new MultiField();
	    multi_kirim_tm_ts.setFieldLabel("TM");
	    multi_kirim_tm_ts.setSpacing(30);
	    
	    tm_kirim = new TextField<String>();
//	    DateField berangkat = new DateField();
	    tm_kirim.setName("tm");  
	    tm_kirim.setFieldLabel("TM");    
	    tm_kirim.setWidth(90);
	    tm_kirim.setReadOnly(true);
//	    fieldSet2.add(tm_kirim, formData);	
	    
	    multi_kirim_tm_ts.add(tm_kirim);
	    
	    LabelField lts = new LabelField("TS:");
	    lts.setWidth(20);
	    multi_kirim_tm_ts.add(lts);
	    
	    
	    ts_kirim = new TextField<String>();
//	    DateField tiba = new DateField();
	    ts_kirim.setName("ts");  
	    ts_kirim.setWidth(90);
	    ts_kirim.setReadOnly(true);
//	    ts_kirim.setFieldLabel("TS");    
//	    fieldSet2.add(ts_kirim, formData);
	    
	    multi_kirim_tm_ts.add(ts_kirim);
	    
	    fieldSet2.add(multi_kirim_tm_ts, formData);
	    
	    TextField<String> hgi_kirim = new TextField<String>();
//	    DateField tiba = new DateField();
	    hgi_kirim.setName("hgi");  
	    hgi_kirim.setWidth(90);
	    hgi_kirim.setReadOnly(true);
	    hgi_kirim.setFieldLabel("HGI");    
	    fieldSet2.add(hgi_kirim, formData);	    
	    	    	   
	    TextField<String> vol_kirim = new TextField<String>();
	    vol_kirim.setName("vol_kirim");  
	    vol_kirim.setReadOnly(true);
	    vol_kirim.setFieldLabel("Volume");	    
	    fieldSet2.add(vol_kirim, formData);
	    
	    TextField<String> nama_surveyor = new TextField<String>();
	    nama_surveyor.setName("nama_surveyor");  
	    nama_surveyor.setReadOnly(true);
	    nama_surveyor.setFieldLabel("Surveyor");	    
	    fieldSet2.add(nama_surveyor, formData);
	    	    
	    final TextField<String> idTransportir = new TextField<String>();  
	    idTransportir.setName("id_transportir");
	    idTransportir.setVisible(false);
	    idTransportir.setFieldLabel("id_transportir");    
	    fieldSet.add(idTransportir, formData);

	    
	    panel.add(fieldSet2);
	    


	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);	    
	    p.setButtonAlign(HorizontalAlignment.RIGHT);  
	    p.addButton(new Button("Reset", new SelectionListener<ButtonEvent>() {  
	      @Override  
	      public void componentSelected(ButtonEvent ce) {  
//	        grid.getStore().rejectChanges();  
	      }  
	    }));  
	    bSubmit = new Button("Submit"); 
	    p.addButton(bSubmit);
	    
	    bSubmit.addSelectionListener( new SelectionListener<ButtonEvent>() {  
	      @Override  
	      public void componentSelected(ButtonEvent ce) {
	    	  
	    	  MessageBox.confirm("Info", "Apakah Anda Yakin Ingin Menyimpan Data?",new Listener<MessageBoxEvent>() {

					@Override
					public void handleEvent(MessageBoxEvent be) {
						// TODO Auto-generated method stub
						Button btn = be.getButtonClicked();
						if (btn.getText().equals("Yes")){

				//	        grid.getStore().commitChanges();  
					    	   Map mapParam = new FastMap();
					    	   
					            mapParam.put("time_bongkar", time_bongkarD.getRawValue() + " "+ time_bongkarT.getRawValue());
					    		mapParam.put("tanggal", time_bongkarD.getRawValue());
					    		mapParam.put("no_bongkar", no_bongkar.getValue());
					    		mapParam.put("alat_bongkar", alat_bongkar.getValue());
					    	    mapParam.put("id_pltu", Registry.get("idPltu").toString());
					    		mapParam.put("updateby", Registry.get("whoAmI").toString());
					    		mapParam.put("app_access", "WEB");
				   			mapParam.put("crud", "UPDATE");
				//
					    		
					    		Set set = mapParam.entrySet();  
					    		Iterator i = set.iterator(); 
					    		while(i.hasNext()) { 
					    		Map.Entry me = (Map.Entry)i.next(); 
						    		GWT.log(me.getKey() + ": " + me.getValue()); 
					    		} 
				
					    		service.insertDermagaBb("BONGKAR", mapParam,new AsyncCallback<List<Map>>() {
					    			public void onFailure(Throwable caught) {
					    				GWT.log(caught.getMessage(), null);
					    			}
				
					    			public void onSuccess(List<Map> result) {	    				
					    				Info.display("debug ","notification code " + result );	    					    				
					    				aktivitasDermaga("antri","BONGKAR","", "");
					    				aktivitasDermaga("antri","SANDAR","", "");
					    				MessageBox.alert("Informasi", " " + result, null);
					    			}
					    		});
						   }
					    }
					});  		    	  
	      }  
	    });  

	    panel.add(p);
	    
	    return panel;  
	  }  
	  private Grid createGridSandar() {  
		  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     
		    
		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Pemasok");  
		    column.setWidth(150);  
		    configs.add(column); 

		    
		    column = new ColumnConfig();  
		    column.setId("nama_transport");  
		    column.setHeader("Nama kapal");    
		    column.setWidth(150);    
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("no_pengiriman");  
		    column.setHeader("No Pengiriman");  
		    column.setWidth(100);  
		    configs.add(column);  	
		    
		    column = new ColumnConfig();  
		    column.setId("kode_jetty");  
		    column.setHeader("Jetty");  
		    column.setWidth(100);  
		    configs.add(column);  	  
		    
		    column = new ColumnConfig();  
		    column.setId("time_merapat");  
		    column.setHeader("Mulai Sandar");  
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy hh.mm"));
		    column.setWidth(150);  
		    configs.add(column);  



		    
//		    ListStore<BbMstPembangkitBean> store = new ListStore<BbMstPembangkitBean>();  
		    storeKplSandar.setMonitorChanges(true);  
//		    store.add(TestData.getMstPembangkit());
		  
		    ColumnModel cm = new ColumnModel(configs);  
	  
	    gridKplSandar = new Grid(storeKplSandar, cm);  
	    gridKplSandar.getView().setEmptyText("Data Empty");
	    gridKplSandar.setLoadMask(true);  
	    gridKplSandar.mask("load Data ...","x-mask-loading");
	    gridKplSandar.setBorders(false);  
//	    grid.setAutoExpandColumn("pemasok");  
	    gridKplSandar.setBorders(true);  
	    gridKplSandar.addListener(Events.CellClick, new Listener<BaseEvent>() {            
        public void handleEvent(BaseEvent ge) {
        	try{

//        		String tgl_td = gridKplSandar.getSelectionModel().getSelectedItem().get("tgl_td");
//        		String norakor = gridKplAntri.getSelectionModel().getSelectedItem().get("kode_jetty").toString();
//            	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy"); 
//            	Date tgl = dateFormat.parse(test);
        		String mulai_sandar = gridKplSandar.getSelectionModel().getSelectedItem().get("time_merapat");
        		time_sandarT.setRawValue("00.00");
        		time_sandarD.setRawValue(mulai_sandar);
            	ash_kirim.setValue(gridKplSandar.getSelectionModel().getSelectedItem().get("ash").toString());
            	cv_kirim.setValue(gridKplSandar.getSelectionModel().getSelectedItem().get("cv").toString());
            	ts_kirim.setValue(gridKplSandar.getSelectionModel().getSelectedItem().get("ts").toString());
            	tm_kirim.setValue(gridKplSandar.getSelectionModel().getSelectedItem().get("tm").toString());

            	
        	}catch (Exception e) {
					// TODO: handle exception
        		e.getMessage();
				}

         	
        }
		});

	    return gridKplSandar;  
	  }   

	  private void aktivitasDermaga(String module, final String codectrl , String put1,String param1){
		  Map mapParam = new FastMap();
		  mapParam.put("id_pltu", Registry.get("idPltu").toString());
			  service.getListDermagaBy(codectrl, mapParam,new AsyncCallback<List<Map>>() {
		  			public void onFailure(Throwable caught) {
		  				GWT.log(caught.getMessage(), null);
		  			}
		  			public void onSuccess(List<Map> result) {
		  			     if (codectrl.equals("SANDAR")){
		  			    	storeKplSandar.removeAll();
		  			    	storeKplSandar.add(ClientModule.setListBaseModelFromListMap(result));
		  			    	gridKplSandar.unmask();
		  			     }else if(codectrl.equals("BONGKAR")){
			  			    	storeKplBongkar.removeAll();
			  			    	storeKplBongkar.add(ClientModule.setListBaseModelFromListMap(result));
			  			    	gridKplBongkar.unmask();
		  			    	 
		  			     }
		  			   
		  			}
		  		});
	  }

}
